package org.demis.dwarf.core.object;

import java.util.ArrayList;
import java.util.List;

public class Entity {
    
    private List<RawAttribute> rawAttributes = new ArrayList<RawAttribute>();
    
    private List<ManyToOne> manyToOnes = new ArrayList<ManyToOne>();

    private List<OneToMany> oneToManies = new ArrayList<OneToMany>();
    
    private Id id;

    private String name = null;

    public Entity() {
        // no op
    }

    public List<RawAttribute> getRawAttributes() {
        return rawAttributes;
    }

    public void setRawAttributes(List<RawAttribute> rawAttributes) {
        this.rawAttributes = rawAttributes;
    }

    public void addRawAttribute(RawAttribute rawAttribute) {
        this.rawAttributes.add(rawAttribute);
    }

    public List<ManyToOne> getManyToOnes() {
        return manyToOnes;
    }

    public void setManyToOnes(List<ManyToOne> manyToOnes) {
        this.manyToOnes = manyToOnes;
    }
    
    public void addManyToOne(ManyToOne manyToOne) {
        this.manyToOnes.add(manyToOne);
    }

    public List<OneToMany> getOneToManies() {
        return oneToManies;
    }

    public void setOneToManies(List<OneToMany> oneToManies) {
        this.oneToManies = oneToManies;
    }

    public void addOneToMany(OneToMany oneToMany) {
        this.oneToManies.add(oneToMany);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Id getId() {
        return id;
    }

    public void setId(Id id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Entity other = (Entity) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
//        if (this.packageDescriptor != other.packageDescriptor && (this.packageDescriptor == null || !this.packageDescriptor.equals(other.packageDescriptor))) {
//            return false;
//        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0);
//        hash = 41 * hash + (this.packageDescriptor != null ? this.packageDescriptor.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
//        return packageDescriptor != null ? packageDescriptor + "." + className : className ;
        return name ;
    }
}
